<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit"/><!-- 让360浏览器默认选择webkit内核 -->
    <!-- <link href="${ctxPath}/static/css/plugins/ztree/demo.css" rel="stylesheet"> -->
    <!--selectpicker-->
    <link href="${ctxPath}/static/js/plugins/selectpicker/bootstrap-select.min.css" rel="stylesheet">

    <!-- 全局js -->
    <script src="${ctxPath}/static/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctxPath}/static/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctxPath}/static/js/plugins/ztree/jquery.ztree.all.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/validate/bootstrapValidator.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/validate/zh_CN.js"></script>
    <script src="${ctxPath}/static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/jquery-treegrid/js/jquery.treegrid.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/jquery-treegrid/js/jquery.treegrid.bootstrap3.js"></script>
    <script src="${ctxPath}/static/js/plugins/jquery-treegrid/extension/jquery.treegrid.extension.js"></script>
    <script src="${ctxPath}/static/js/plugins/layer/layer.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/iCheck/icheck.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/layer/laydate/laydate.js"></script>
    <script src="${ctxPath}/static/js/plugins/webuploader/webuploader.min.js"></script>
    <script src="${ctxPath}/static/js/common/ajax-object.js"></script>
    <script src="${ctxPath}/static/js/common/bootstrap-table-object.js"></script>
    <script src="${ctxPath}/static/js/common/tree-table-object.js"></script>
    <script src="${ctxPath}/static/js/common/web-upload-object.js"></script>
    <script src="${ctxPath}/static/js/common/ztree-object.js"></script>
    <script src="${ctxPath}/static/js/common/Feng.js"></script>
    <script src="${ctxPath}/static/js/plugins/selectpicker/bootstrap-select.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/selectpicker/defaults-zh_CN.js"></script>
    <script src="${ctxPath}/static/js/plugins/bootstrap-table/bootstrap-table-export.min.js"></script>
    <script src="${ctxPath}/static/js/plugins/bootstrap-table/tableExport.min.js"></script>

    <script type="text/javascript">
        Feng.addCtx("${ctxPath}");
        Feng.sessionTimeoutRegistry();
    </script>
    <style>
        .toothNone{border:  none;outline:  none;background: none;display: inline-block;width: 46%;height: 12px;}
        .leftUp{border-right: 1px solid #666666;border-bottom: 1px solid #666666;text-align: right;padding-right: 4px;position: absolute}
        .rightUp{border-bottom: 1px solid #666666;padding-left: 4px;position: absolute;right: 0;}
        .leftDown{border-right: 1px solid #666666;text-align: right;padding-right: 4px;position: absolute;bottom: 0px;}
        .rightDown{padding-left: 4px;margin-left: -10px;position: absolute}
    </style>
</head>

<body class="gray-bg">
<script src="${ctxPath}/static/js/content.js?v=1.0.0"></script>
<div style="display: none">
    <input type="hidden" id="customerId" value="${customerId}">
    <input type="hidden" id="reservationsId" value="${reservationsId}">
    <input type="hidden" id="operationTime" value="${operationTime}">
    <input type="hidden" id="getTime" value="${getTime}">
</div>
<div id="div_print" class="print_box" style="word-break:break-all;padding: 0 50px;">
    <div style="word-break:break-all;font-size: 16px;color: black">
        <div class="data_row" style="text-align: center;margin-bottom: 10px;margin-top: 10px">
            <span style="font-size: 21px;font-weight: bold;display: inline-block;">咿呀口腔${deptInfo.simplename}</span>
        </div>
        <div class="data_row" style="border-bottom: 1px solid black;display: flex">
            <div style="flex: 1">姓名:${consultantInfo.customerName}</div>
            <div style="flex: 2;padding-left: 10px;">病历号:${consultantInfo.medicalRecordNumber}</div>
            <div style="flex: 1">性别:${consultantInfo.sex}</div>
            <div style="flex: 2">联系电话:${consultantInfo.customerPhone}</div>
            <div style="flex: 2;text-indent: 1em;">单据号:<span id="documentNumber"></span></div>
        </div>
        <div class="data_row" style="font-weight: bold;border-bottom: 1px solid black;margin-top: 5px;display: flex">
            <div style="flex: 1;text-align: center">牙位</div>
            <div style="flex: 3;text-indent: 1em;">处置名称</div>
            <div style="flex: 1;text-align: center">数量</div>
            <div style="flex: 1;text-align: center">单位</div>
            <div style="flex: 1;text-align: center">单价</div>
            <div style="flex: 1;text-align: center">金额</div>
        </div>

        <div id="plan_box" style="height: 220px;">
            <!--<div class="data_row" style="margin-top: 5px;display: none">-->



                <!--<div style="padding-left: 10px;width: 120px;display: inline-block;">-->
                    <!--<div style="border-bottom: 1px solid;">-->
                        <!--<div style="display: inline-block;width:55px;;border-right: 1px solid black;text-align: right"-->
                             <!--id="yw_left_top"></div>-->
                        <!--<div style="display: inline-block;width:55px;" id="yw_right_top"></div>-->
                    <!--</div>-->
                    <!--<div>-->
                        <!--<div style="display: inline-block;width:55px;;border-right: 1px solid black;text-align: right"-->
                             <!--id="yw_left_bottom"></div>-->
                        <!--<div style="display: inline-block;width:55px;" id="yw_right_bottom"></div>-->
                    <!--</div>-->
                <!--</div>-->
                <!--<div style="width: 140px;display: inline-block;position: relative;top: -12px;" id="disposal">-->
                    <!--热牙胶+机用扩大系统磨牙-->
                <!--</div>-->
                <!--<div style="width: 45px;display: inline-block;position: relative;top: -12px;" id="number">1</div>-->
                <!--<div style="width: 100px;display: inline-block;position: relative;top: -12px;" id="unit">1280.00</div>-->
                <!--<div style="width: 100px;display: inline-block;position: relative;top: -12px;" id="price">1280.00</div>-->
                <!--<div style="width: 100px;display: inline-block;position: relative;top: -12px;" id="amount">1280.00</div>-->
            <!--</div>-->
        </div>

        <div class="data_row fz2" style="border-top: 1px solid black;padding-top: 2px;display: flex">
            <div style="flex: 1;">合计应收:<span id="hjys"></span></div>
            <div style="flex: 1;">上次欠款:</div>
            <div style="flex: 1;">本次欠款:<span id="bcqk"></span></div>
            <div style="flex: 1;">折扣率:<span id="zkl"></span></div>
            <div style="flex: 1;">本次费用:<span id="bcfy"></span></div>
        </div>
        <div class="data_row fz2" style="display: flex">
            <div style="flex: 2;">收款方式:<span id="skfs"></span></div>
            <div style="flex: 1;">折扣金额:<span id="zkje"></span></div>
            <div style="flex: 1;">实收金额:<span id="ssje"></span></div>
            <div style="flex: 1;">实收金额(大写):</div>
        </div>
        <div class="data_row fz2" style="border-top: 1px solid;padding-top: 2px;display: flex">
            <div style="flex: 2;">医生:<span id="doctor"></span></div>
            <div style="flex: 1;">收银员:${userName}</div>
            <div style="flex: 1;">医助/护士:${rechargeInfo.nurse}</div>
            <div style="flex: 1;">咨询师:<span id="tc"> ${consultantInfo.tcName}</span></div>
        </div>
        <div class="data_row fz2" style="display: flex;">
            <div style="flex: 2;">地址:${deptInfo.address}</div>
            <div style="flex: 1"></div>
            <div style="flex: 1;">电话:${deptInfo.phone}</div>
        </div>

        <div class="data_row fz2" style="display: flex">
            <div style="flex: 2;">收款时间:<span id="nowTime"></span></div>
            <div style="flex: 1"></div>
            <div style="flex: 1;">收款单位(盖章):</div>
        </div>
    </div>
</div>

<div style="position: absolute;bottom: 5%;left: 49%">
    <input name="print" type="button" id="bt" value="点击打印"/>
</div>
<script>
    var nowTime = document.getElementById('nowTime');
    var doctor = document.getElementById('doctor');
    var tc = document.getElementById('tc');
    var ssje = document.getElementById('ssje');
    var hjys = document.getElementById('hjys');
    var zkje = document.getElementById('zkje');
    var bcqk = document.getElementById('bcqk');
    var zkl = document.getElementById('zkl');
    var bcfy = document.getElementById('bcfy');
    var skfs = document.getElementById('skfs');
    var documentNumber = document.getElementById('documentNumber');
    var money_all = 0;
    var hjys_money = 0;
    var ssje_money = 0;
    var bcqk_money = 0;
    var operationTime = document.getElementById("operationTime").value;
    var reservationsId = document.getElementById("reservationsId").value;
    var getTime = document.getElementById("getTime").value;
    var customerId = document.getElementById("customerId").value;
    var getTime = document.getElementById("getTime").value;
    //页面计算赋值
    nowTime.innerText = getNowFormatDate();

    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        return currentdate;
    };
    $.ajax({
        url: Feng.ctxPath + "/consultant/getOpenPrint",
        type: "post",
        data: {
            "operationTime": operationTime,
            "reservationsId": reservationsId,
            "getTime": getTime,
            "customerId": customerId
        },
        success: function (data) {
            var arr = data;
            var plan_box = document.getElementById('plan_box');
            for (var i = 0; i < arr.length; i++) {
                var plan_child = document.createElement('div');
                if (arr[i].payServiceName == null || arr[i].payServiceName == "") {
                    var str = " ";
                    plan_child.innerHTML = str;
                    plan_box.appendChild(plan_child);
                    money_all += 0.00;
                    hjys_money += 0.00;
                    bcqk_money += 0.00;
                    doctor.innerText += arr[i].doctor + " ";
                } else {
                    var str = '<div style="display: flex;height: 28px;line-height: 28px;">' +
                        '<div style="flex: 1;position: relative">' +
                        '<input readonly="readonly" class="toothNone leftUp" type="text" value="'+ arr[i].leftUp + '" id="yw_left_top">' +
                        '<input readonly="readonly" class="toothNone rightUp" type="text" value="'+ arr[i].rightUp +'" id="yw_right_top">' +
                        '<input readonly="readonly" class="toothNone leftDown" type="text" value="'+ arr[i].leftDown +'" id="yw_left_bottom">' +
                        '<input readonly="readonly" class="toothNone rightDown" type="text" value="'+ arr[i].rightDown + '" id="yw_right_bottom">' +
                        '</div>' +
                        '<div style="flex: 3;text-indent: 1em;" id="disposal">' + arr[i].payServiceName + '</div>' +
                        '<div style="flex: 1;text-align: center" id="number">' + arr[i].payServiceNum + '</div>' +
                        '<div style="flex: 1;text-align: center" id="unit">' + arr[i].unit + '</div>' +
                        '<div style="flex: 1;text-align: center" id="price">' + arr[i].payService + '</div>' +
                        '<div style="flex: 1;text-align: center" id="amount">' + parseFloat(arr[i].payServiceNum) * parseFloat(arr[i].payService) + '</div>' +
                        '</div>';
                        plan_child.innerHTML = str;
                        plan_box.appendChild(plan_child);
                        money_all += parseFloat(arr[i].payServiceNum) * parseFloat(arr[i].payService);
                        hjys_money += parseFloat(arr[i].foldingPay);
                        bcqk_money = parseFloat(arr[i].accountArrears);
                        doctor.innerText += arr[i].doctor + " ";
                }
            }
            hjys.innerText = hjys_money.toFixed(2);
            bcqk.innerText = bcqk_money.toFixed(2);
            var zkjes = parseFloat(money_all).toFixed(2) - parseFloat(hjys_money);
            zkje.innerText = zkjes.toFixed(2);
            bcfy.innerText = money_all.toFixed(2);
            $.ajax({
                url: Feng.ctxPath + "/consultant/getCheckoutMethod",
                type: "post",
                data: {
                    "operationTime": operationTime,
                    "reservationsId": reservationsId,
                    "getTime": getTime,
                    "customerId": customerId
                },
                success: function (data1) {
                    console.log(data1);
                    var str = "";
                    for (var k = 0; k < data1.length; k++) {
                        str += data1[k].checkoutMethod + " " + data1[k].actualAccountBalance.toFixed(2);
                        ssje_money += parseFloat(data1[k].actualAccountBalance);
                        documentNumber.innerText = data1[k].documentNumber;
                    }
                    skfs.innerText = str;
                    ssje.innerText = ssje_money.toFixed(2);
                    zkl.innerText = ((parseFloat(hjys_money) / parseFloat(money_all)) * 100).toFixed(2);
                    if (hjys_money < ssje_money) {
                        hjys.innerText = ssje_money.toFixed(2);
                        bcfy.innerText = ssje_money.toFixed(2);
                        zkl.innerText = ((parseFloat(ssje_money) / parseFloat(ssje_money)) * 100).toFixed(2);
                    }
                },
                error: function (data1) {
                    alert('内部故障！请联系管理员！');
                }
            });
        },
        error: function (data) {
            alert('内部故障！请联系管理员！');
        }
    });


    //打印代码
    var bt = document.getElementById("bt");
    var div_print = document.getElementById("div_print");
    bt.onclick = function () {
        printdiv(div_print);
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    };

    function printdiv(printpage) {
        var newstr = printpage.innerHTML;
        var oldstr = document.body.innerHTML;
        document.body.innerHTML = newstr;
        window.print();
        document.body.innerHTML = oldstr;
        console.log('打印成功');
        return false;
    }

</script>
</body>
</html>
